import request from '@/utils/request';
import axios from 'axios'

let baseUrl = '';
let h5Url = '';
let siderImgUrl = '';
switch (process.env.VUE_APP_BASE_API) {
  case 'QA':   //内网QA
    baseUrl = "http://192.168.1.54/api";
    h5Url = 'http://vrhcp-dev.huimeihealth.com.cn/browse';   //h5测试dev域名
    break;
  case 'build':   //生产-线上
    baseUrl = "https://vr.huimeimt.com/api";
    h5Url = 'http://vrhcp.huimeihealth.com.cn/browse';    //h5线上域名
    siderImgUrl = 'https://vr.huimeimt.com/';
    break;
  case 'TEST':   //生产测试--内网测试
    baseUrl = "http://222.128.32.155:9527/api";
    // baseUrl = "http://192.168.1.200/api";
    h5Url = 'http://vrhcp-dev.huimeihealth.com.cn/browse';  //h5测试dev域名
    siderImgUrl = 'http://222.128.32.155:9527/';
    break;
  default:   //本地
    baseUrl = "http://192.168.1.210:8889";
    h5Url = 'http://192.168.1.166/api';  //h5测试dev域名
    siderImgUrl = 'http://192.168.1.210:8889/'
    break;
}
const api = {
  //登录
  login: {
    url: '/representative/login',
    method: 'POST'
  },
  //客户跟进/我的客户列表
  my_customer_list: {
    url: '/call_record_info/getRepDoctorToPage',
    method: 'POST'
  },
  //客户跟进/拨打电话列表
  call_phone_list: {
    url: '/doctors/find/info',
    method: 'POST'
  },
  //客户跟进/拨打电话未接通
  add_call_record: {
    url: '/call_record_info/addCallRecordInfo',
    method: 'POST'
  },
  //客户跟进/添加拜访记录
  add_visited_record: {
    url: '/call_record_info/Badd',
    method: 'POST'
  },
  //药企列表
  enterprise_list: {
    url: '/enterprise/get/list',
    method: 'GET'
  },
  //根据药企获取产品
  product_url: '/product/get/',
  product: {
    url: '/product/get',
    method: 'GET'
  },
  //客户跟进/通话中，拜访记录/医生基本信息
  doctor_info_url: '/doctors/by/id',
  doctor_info: {
    // url: '/doctors/by/id',
    method: 'POST'
  },
  //客户跟进/通话中，拜访记录/医生对应产品信息
  doctor_product_url: '/product/select/product/byRepIdDoctorId',
  doctor_product: {
    // url: '/product/select/product/byRepIdDoctorId',
    method: 'POST'
  },
  //历史拜访记录列表
  history_visit_record: {
    url: '/call_record_info/getCallRecordInfoToPage',
    method: 'POST'
  },
  //历史拜访记录详情
  history_visit_detail_url: '/call_record/getCallRecordInfoListToPage',
  history_visit_detail: {
    method: 'GET'
  },
  //根据医生手机获取医生id
  get_doctor_id_by_phone_url: '/contact/by/',
  get_doctor_id_by_phone: {
    method: 'GET'
  },
  //获取微信代表与医生聊天信息
  get_wechat_talk_info_url: '/get_wechat_record',
  get_wechat_talk_info: {
    method: 'GET'
  },
  //微信用户列表
  weixin_customer_list: {
    url: '/repdoctorproduct/find/info/toPage',
    method: 'POST'
  },
  edit_weixin_customer: {
    url: '/repdoctorproduct/update/info',
    method: 'POST'
  },
  consult_weixin_doctor_url: '/repdoctorproduct/get/info/',
  consult_weixin_doctor: {
    method: 'GET'
  },
  edit_weixin_delete_url: '/repdoctorproduct/delete/info/',
  edit_weixin_delete: {
    method: 'GET'
  },
  //根据医生id获取最近一次通话状态
  get_call_status_url: '/call_record_info/get/callStatus/',
  get_call_status: {
    method: 'POST'
  },
  //根据医生id修改医生信息
  update_doctor_info_url: '/doctors/update',
  update_doctor_info: {
    method: 'POST'
  },
//  修改密码》查询旧密码是否正确
  query_password: {
    url: '/representative/pwd/exist',
    method: 'POST'
  },
  //  修改密码》代表修改密码接口
  change_password: {
    url: '/representative/update/pwd',
    method: 'POST'
  },
  //电话代表》补充填报
  supplement: {
    url: '/call_record_info/supplement',
    method: 'POST'
  },
  //微信拜访结果
  get_wechat_result_url: '/repdoctorproduct/find/wechat_result',
  get_wechat_result: {
    method: 'POST'
  },
  //获取微信代表
  get_wechat_rept_url: '/repdoctorproduct/find/wechat_rep/',
  get_wechat_rept: {
    method: 'GET'
  },
//拜访记录查询
  selectCallRecordListToPage: {
    url: '/call_record/selectCallRecord/ListToPage',
    method: 'POST'
  },
// 综合查询-拜访记录excel下载
  downloadEasyExcel: {
    url: '/easy_excel/downloadEasyExcel',
    method: 'POST'
  },
  //获取快捷标签
  get_resource_item_url: '/resource/getReourceItem/',
  get_resource_item: {
    method: 'GET'
  },
  //我的医生列表
  get_my_doctor_info: {
    url: '/call_record_info/getMyDoctorToPage',
    method: 'POST'
  },
  //获取医生拜访记录
  get_vist_record_url: '/call_record/getCallRecordInfoListToPage',
  get_vist_record: {
    method: 'POST'
  },
  //获取医生基础标签
  get_doctor_basic_label_url: '/tag_base/tag_base_doctor_info',
  get_doctor_basic_label: {
    method: 'POST'
  },
  //获取医生项目标签
  get_doctor_project_basic_url: '/tag_product/tag_product_doctor_info',
  get_doctor_project_basic: {
    method: 'POST'
  },
  //判断号码是否可以拨打
  search_phone_url: '/doctors/serchDoctorContact',
  search_phone: {
    method: 'POST'
  },
  //获取代表下所属的产品
  get_product_by_id_url: '/product/getProduct/By/',
  get_product_by_id: {
    method: 'GET'
  },
  //获取项目对应招募状态
  get_product_recruit_status_url: '/doctors/getRecruitByDoctorIdAndProductId',
  get_product_recruit_status: {
    method: 'POST'
  },
  //区分通话来源
  call_source: {
    url: '/diaout_record/insert_diaout_record',
    method: 'POST'
  },
  //查看项目标签/tag_product/tag_product_info_list
  tag_product_info_list: {
    url: '/tag_product/tag_product_info_list',
    method: 'POST'
  },
  tag_product_info: {
    url: '/tag_product/tag_product_info',
    method: 'POST'
  },
  ///tag_base/tag_base_info  // 查看基础标签
  tag_base_info: {
    url: '/tag_base/tag_base_info',
    method: 'POST'
  },
  //添加拜访结果
  add_visit_record: {
    url: '/call_record_info/plusAdd',
    method: 'POST'
  },
  //补充填报
  visit_supplementPlus: {
    url: '/call_record_info/supplementPlus',
    method: 'POST'
  },
  //基础标签
  visit_result_basic_label_url: '/tag_base/tag_option_info_base_list',
  visit_result_basic_label: {
    method: 'GET'
  },
  //项目标签
  visit_result_product_label_url: '/tag_product/tag_option_info_product_list',
  visit_result_product_label: {
    method: 'GET'
  },
  //获取医院信息
  get_hospital_info: {
    url: '/hospital/searchHospitalInfo',
    method: 'POST'
  },
  //获取医生信息
  get_doctor_info: {
    url: '/doctors/searchDoctorInfo',
    method: 'POST'
  },
  //获取医生对应项目
  get_doctor_project_list_url: '/product/getDoctorProduct/',
  get_doctor_project_list: {
    method: 'GET'
  },
  //编辑医生信息
  edit_doctor_infos: {
    url: '/doctors/update/base/data',
    method: 'POST'
  },
  //编辑医院信息
  edit_hospital_info: {
    url: '/hospital/update/hospital',
    method: 'POST'
  },
  //获取省份
  get_all_province: {
    url: '/province/all',
    method: 'GET'
  },
  //获取城市
  get_city_url: '/city/by/',
  get_city: {
    method: 'GET'
  },
  //获取所有医院
  get_all_hospital: {
    url: '/hospital/getAllHospitalInfo',
    method: 'POST'
  },
  //获取药企
  get_enterprise_list_url: '/enterprise/select_enterprise',
  get_enterprise_list: {
    method: 'POST'
  },
  //添加药企
  add_enterprise: {
    url: '/enterprise/insert_enterprise',
    method: 'POST'
  },
  //修改药企
  update_enterprise: {
    url: '/enterprise/update_enterprise',
    method: 'POST'
  },
  //删除药企
  delete_enterprise_url: '/enterprise/delete_enterprise',
  delete_enterprise: {
    method: 'GET'
  },
  //获取所有产品
  get_all_product: {
    url: '/product/getAllProductInfo',
    method: 'POST'
  },
  //题库管理列表
  get_question_list: {
    url: '/question_bank/select_question',
    method: 'POST'
  },
  //添加问题
  add_question: {
    url: '/question_bank/insert_question',
    method: 'POST'
  },
  //编辑问题
  edit_question: {
    url: '/question_bank/update_question',
    method: 'POST'
  },
  //删除问题
  delete_question_url: '/question_bank/delete_question',
  delete_question: {
    method: 'POST'
  },
  //项目管理列表
  project_list_url: '/project/select_project',
  project_list: {
    method: 'POST'
  },
  //添加项目
  add_project: {
    url: '/project/insert_project',
    method: 'POST'
  },
  //编辑项目
  edit_project: {
    url: '/project/update_project',
    method: 'POST'
  },
  //删除项目
  delete_project_url: '/project/delete_project',
  delete_project: {
    method: 'POST'
  },
  //目标医院管理列表
  target_hospital_list: {
    url: '/target_hospital/seleTargetctHospiralByName',
    method: 'POST'
  },
  //项目医生管理列表
  project_doctor_list: {
    url: '/repdoctorproduct/selectDoctorProduct',
    method: 'POST'
  },
  //产品对应代表
  get_product_rept: {
    url: '/representative/getRepNamebyProductId',
    method: 'POST'
  },
  //查看医院名称是否存在
  hospital_exist_url: '/hospital/exist/',
  hospital_exist: {
    method: 'GET'
  },
  //文章列表
  get_article_list: {
    url: '/article/selectArticleToPage',
    method: 'POST'
  },
  //删除文章
  delete_article_url: '/article/deleteArticleInfo',
  delete_article: {
    method: 'GET'
  },
  //添加文章
  add_article_url: '/article/insertArticleInfo',
  //编辑文章
  edit_article_info_url: '/article/updateArticleInfo',
  //问卷列表
  get_questionnaire_list: {
    url: '/questionnaire/getQuestionnairePage',
    method: 'POST'
  },
  //获取问卷列表末次更新时间
  get_questionnaire_last_update_time_url: '/questionnaire/get_sync_time',
  get_questionnaire_last_update_time: {
    method: 'GET'
  },
  //同步问卷列表数据
  sync_questionnaire_list_url:'/questionnaire/sync_questionnarie_all',
  sync_questionnaire_list: {
    method: 'POST'
  },
  //同步问卷数据状态
  sync_questionnaire_status:{
    url:'/questionnaire/sync/status',
    method:'GET'
  },
  //编辑问卷信息
  edit_questionnaire_info_url: '/questionnaire/editQuestionnaire',
  //上传图片
  upload_url: '/article/ArticleImgUpload',
  //获取直播列表
  get_live_list: {
    url: '/live/channel/select/page',
    method: 'POST'
  },
  //编辑直播信息
  edit_live_info_url: '/live/channel/update/info',
  //获取点播列表
  get_demand_list: {
    url: '/live-video-demand/selectDemandToPage',
    method: 'POST'
  },
  //获取相关直播标题
  get_live_title: {
    url: '/live/channel/getList',
    method: 'POST'
  },
  //编辑点播
  edit_demand_info_url: '/live-video-demand/demand/updateInfo',
  //医生基本信息-活动记录
  get_doctor_activity_record: {
    url: '/activity/getActivityToPage',
    method: 'POST'
  },
  //医生基本信息-活动记录-问卷详情
  get_questionnaire_info:{
    url:'/questionnaire/getQuestionnaireInfo',
    method:'POST'
  },
  //同步直播/点播数据
  live_sync_data_url:'/live/sync/all_data',
  live_sync_data:{
    method:'POST'
  },
  //直播/点播同步数据状态
  get_live_status:{
    url:'/live/sync/status',
    method:'GET'
  },
  //直播/点播末次更新时间
  get_live_last_update_time:{
    url:'/live/get_sync_time',
    method:'GET'
  }
}

let baseAjax = function (url_info, data, callBack) {
  request({
    url: baseUrl + url_info.url,
    method: url_info.method,
    data
  }).then(function (res) {
    callBack(res)
  }).catch(function (error) {
    console.log(error)
  })
}
const decryptMobile = function (data) {
  return axios({
    url: baseUrl + '/contactComponent/decryptMobile',
    method: 'post',
    data: data,
  })
}

export {api, baseAjax, baseUrl, h5Url, decryptMobile, siderImgUrl}

